var root={};
root.Pdf={};
root.Pdf.view=function(options){

	if (!PDFJS.PDFViewer || !PDFJS.getDocument) {
	  alert('非常抱歉，PDF环境不正确，无法查看PDF文件');
	  return;
	}

	var DEFAULT_URL = options.url;
	if(DEFAULT_URL===undefined || DEFAULT_URL===null){
		alert("文件地址不可访问，无法查看PDF文件");
		return;
	}else{
		DEFAULT_URL = options.ctx+"/u/r/cards/"+DEFAULT_URL;
	}
	var containerName = 'viewerContainer';
	if(options.container!==undefined){
		containerName=options.container;
	}
	var container = document.getElementById(containerName);
	var pdfViewer = new PDFJS.PDFViewer({
	  container: container
	});

	container.addEventListener('pagesinit', function () {
	  // we can use pdfViewer now, e.g. let's change default scale.
	  pdfViewer.currentScaleValue = 'page-width';
	});

	// Loading document.
	PDFJS.getDocument(DEFAULT_URL).then(function (pdfDocument) {
	  // Document loaded, specifying document for the viewer.
	  pdfViewer.setDocument(pdfDocument);
	});
};